﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using H2.NET.Controls;
using H2.NET.Business;
using H2.NET.Data.Common;

namespace H2.NET.Web.Pages
{
    public partial class PHCMD : TaskPage
    {
        #region 属性 Public
        private bool IsLoaded
        {
            get
            {
                return ViewState["IsLoaded"] == null ? false : (bool)ViewState["IsLoaded"];
            }
            set { ViewState["IsLoaded"] = value; }

        }
        #endregion

        #region 事件 Page Load
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //WorkLoad_L.Text = Actions.SelectedItem.Text.Substring(3);
                INFO.Text = "注意：表单正在被其他同事处理，拒绝提交表单！";
                INFO.Visible = IsOverFlow;

                bool flg = (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) ? true : false;

                #region 发起步骤
                if (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit)
                {
                    InitDropDownList();
                    SetColor();
                }
                #endregion

                #region 审批环节
                if(!TaskAPI.IsInitiate)
                {
                    #region 加载数据并显示
                    hcmd_Customer cst = (hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == TaskAPI.Incident).ListFirst<hcmd_Customer>();
                    if (cst != null)
                    {
                        //Actions.SelectedValue                       = cst.Actions;
                        SetDropDownListValue(Actions, cst.Actions);
                        SetDropDownListValue(DrpPriority, cst.DrpPriority);
                        if (Actions.SelectedValue == "1")
                        {
                            BA_Existed_Sold_To_Code.Visible = false;
                            BA_Existed_Sold_To_Code_L.Visible = false;

                         
                        }
                        SetColor();
                        ApplicationNo.Text                          = cst.ApplicationNo;
                        Keys.Items[0].Selected                      = cst.Keys == "1";
                        Keys.Items[1].Selected                      = cst.Keys2 == "1";

                        //WorkLoad_L.Text = cst.WorkLoad_L;
                        //WorkLoad.Text = cst.WorkLoad;


                        BA_Customer_Name_In_ZH.Text                 = cst.BA_Customer_Name_In_ZH;
                        BA_Business_License_No.Text                 = cst.BA_Business_License_No;


                        BA_Existed_Sold_To_Code.Text                = cst.BA_Existed_Sold_To_Code;
                        //BA_Block_Existed_Code.SelectedValue                  = cst.BA_Block_Existed_Code;
                        SetDropDownListValue(BA_Block_Existed_Code, cst.BA_Block_Existed_Code);
                        //BA_Language.SelectedValue                   = cst.BA_Language;
                        SetDropDownListValue(BA_Language, cst.BA_Language);
                        //BA_Cust_Pric.SelectedValue                  = cst.BA_Cust_Pric;
                        SetDropDownListValue(BA_Cust_Pric, cst.BA_Cust_Pric);

                        BA_Contact_Person.Text                      = cst.BA_Contact_Person;
                        BA_Contact_Person_Mobile_Phone.Text         = cst.BA_Contact_Person_Mobile_Phone;
                        
                        BA_Responsible_Man.Text                     = cst.BA_Responsible_Man;
                        BA_Responsible_Mobile_Phone.Text            = cst.BA_Responsible_Mobile_Phone;
                        
                        //BA_Sales_Employee_K1.Text                   = cst.BA_Sales_Employee_K1;
                        SetDropDownListValue(BA_Sales_Employee_K1, cst.BA_Sales_Employee_K1);
                        BA_Sales_Employee_K1_Mobile_Phone.Text      = cst.BA_Sales_Employee_K1_Mobile_Phone;
                        SetDropDownListValue(BA_Sales_Employee_K1_Ot, cst.BA_Sales_Employee_K1_Ot);
                        BA_Sales_Employee_K1_Mobile_Phone_Ot.Text = cst.BA_Sales_Employee_K1_Mobile_Phone_Ot;
                        
                        //BA_Sales_Employee_K1_Employee_Code.Text     = cst.BA_Sales_Employee_K1_Employee_Code;
                        //BA_Sales_Employee_K2.Text                   = cst.BA_Sales_Employee_K2;
                        SetDropDownListValue(BA_Sales_Employee_K2, cst.BA_Sales_Employee_K2);
                        BA_Sales_Employee_K2_Mobile_Phone.Text      = cst.BA_Sales_Employee_K2_Mobile_Phone;
                        SetDropDownListValue(BA_Sales_Employee_K2_Ot, cst.BA_Sales_Employee_K2_Ot);
                        BA_Sales_Employee_K2_Mobile_Phone_Ot.Text = cst.BA_Sales_Employee_K2_Mobile_Phone_Ot;
                        //BA_Sales_Employee_K2_Employee_Code.Text     = cst.BA_Sales_Employee_K2_Employee_Code;
                        //BA_Sales_Employee_K3.SelectedValue                   = cst.BA_Sales_Employee_K3;
                        SetDropDownListValue(BA_Sales_Employee_K3, cst.BA_Sales_Employee_K3);
                        BA_Sales_Employee_K3_Mobile_Phone.Text      = cst.BA_Sales_Employee_K3_Mobile_Phone;
                        SetDropDownListValue(BA_Sales_Employee_K3_Ot, cst.BA_Sales_Employee_K3_Ot);
                        BA_Sales_Employee_K3_Mobile_Phone_Ot.Text = cst.BA_Sales_Employee_K3_Mobile_Phone_Ot;
                        //BA_Sales_Employee_K3_Employee_Code.Text     = cst.BA_Sales_Employee_K3_Employee_Code;
                        SetDropDownListValue(BA_Sales_Employee_K6, cst.BA_Sales_Employee_K6);
                        BA_Sales_Employee_K6_Mobile_Phone.Text = cst.BA_Sales_Employee_K6_Mobile_Phone;
                        SetDropDownListValue(BA_Sales_Employee_K6_Ot, cst.BA_Sales_Employee_K6_Ot);
                        BA_Sales_Employee_K6_Mobile_Phone_Ot.Text = cst.BA_Sales_Employee_K6_Mobile_Phone_Ot;
                       
                        BA_Existed_Sold_To_Code_2.Text              = cst.BA_Existed_Sold_To_Code_2;
                        //BA_Existed_Sold_To_Code_Country.SelectedValue = cst.BA_Existed_Sold_To_Code_Country;
                        SetDropDownListValue(BA_Existed_Sold_To_Code_Country, cst.BA_Existed_Sold_To_Code_Country);
                        //SetDropDownListValue(BA_Existed_Sold_To_Code_Country, cst.BA_Existed_Sold_To_Code_Country);
                        //if (flg)
                        //{
                        //    BA_Existed_Sold_To_Code_Street5_SelectedIndexChanged(null, e);
                        //}

                        //BA_Existed_Sold_To_Code_City.SelectedValue          = cst.BA_Existed_Sold_To_Code_City;
                        SetDropDownListValue(BA_Existed_Sold_To_Code_City, cst.BA_Existed_Sold_To_Code_City);
                        BA_Existed_Sold_To_Code_Address.Text         = cst.BA_Existed_Sold_To_Code_Address;
                        BA_Existed_Sold_To_Code_Contact_Preson.Text = cst.BA_Existed_Sold_To_Code_Contact_Preson;
                        BA_Existed_Sold_To_Code_Tel.Text            = cst.BA_Existed_Sold_To_Code_Tel;
                        BA_Existed_Bill_To_Code.Text                = cst.BA_Existed_Bill_To_Code;
                        //BA_Existed_Bill_To_Code_Country.SelectedValue = cst.BA_Existed_Bill_To_Code_Country;
                        SetDropDownListValue(BA_Existed_Bill_To_Code_Country, cst.BA_Existed_Bill_To_Code_Country);
                        //SetDropDownListValue(BA_Existed_Bill_To_Code_Country,cst.BA_Existed_Bill_To_Code_Country);
                        //if (flg)
                        //{
                        //    BA_Existed_Bill_To_Code_TextChanged(null, e);
                        //}
                        BA_Existed_Bill_To_Code_City.SelectedValue = cst.BA_Existed_Bill_To_Code_City;
                        SetDropDownListValue(BA_Existed_Bill_To_Code_City, cst.BA_Existed_Bill_To_Code_City);
                        BA_Existed_Bill_To_Code_Address.Text         = cst.BA_Existed_Bill_To_Code_Address;
                        BA_Existed_Bill_To_Code_Contact_Preson.Text = cst.BA_Existed_Bill_To_Code_Contact_Preson;
                        BA_Existed_Bill_To_Code_Tel.Text            = cst.BA_Existed_Bill_To_Code_Tel;
                        BA_DEL_Bill.Text                            = cst.BA_DEL_Bill;
                        BA_Existed_Dunn_Recipient_Code.Text         = cst.BA_Existed_Dunn_Recipient_Code;
                        //BA_Existed_Dunn_Recipient_Country.SelectedValue = cst.BA_Existed_Dunn_Recipient_Country;
                        SetDropDownListValue(BA_Existed_Dunn_Recipient_Country, cst.BA_Existed_Dunn_Recipient_Country);
                        //SetDropDownListValue(BA_Existed_Dunn_Recipient_Country, cst.BA_Existed_Dunn_Recipient_Country);
                        //if (flg)
                        //{
                        //    BA_Existed_Dunn_Recipient_Country_SelectedIndexChanged(null, e);
                        //}
                        BA_Existed_Dunn_Recipient_City.Text         = cst.BA_Existed_Dunn_Recipient_City;
                        
                        BA_Existed_Dunn_Recipient_Address.Text       = cst.BA_Existed_Dunn_Recipient_Address;
                        BA_Existed_Dunn_Recipient_Contact_Preson.Text = cst.BA_Existed_Dunn_Recipient_Contact_Preson;
                        BA_Existed_Dunn_Recipient_Tel.Text          = cst.BA_Existed_Dunn_Recipient_Tel;
                        BA_Region.Text                              = cst.BA_Region;
                        BA_City_Code.Text = cst.BA_City_Code;    

                       

                       

                       // SetDropDownListValue(BA_City_Code, cst.BA_City_Code);
                       
                      
                        
                        //BA_County_Code.Text                         = cst.BA_County_Code;
                        BA_Transportation_Zone.Text                 = cst.BA_Transportation_Zone;
                       
                        SetDropDownListValue(BA_Industry, cst.BA_Industry);
                        SetDropDownListValue(BA_Industry1, cst.BA_Industry1);
                        
                        
                        
                        SA_Sales_Org.Text                           = cst.SA_Sales_Org;
                        //SA_Sales_Office.Text                        = cst.SA_Sales_Office;                        
                        //SA_Distribution_Channel.Text                = cst.SA_Distribution_Channel;
                        //SA_Sales_Employee.Text                      = cst.SA_Sales_Employee;
                        //SA_Sales_Employee_Code.Text                 = cst.SA_Sales_Employee_Code;
                        SA_Customer_Division_K1.Checked             = cst.SA_Customer_Division_K1=="1";
                        SA_Customer_Division_K2.Checked             = cst.SA_Customer_Division_K2=="1";
                        SA_Customer_Division_K3.Checked             = cst.SA_Customer_Division_K3=="1";
                        SA_Customer_Division_K6.Checked = cst.SA_Customer_Division_K6 == "1";

                        //SetDropDownListValue(SA_Price_Group_1, cst.SA_Price_Group_1);
                        //SetDropDownListValue(SA_Price_Group_2, cst.SA_Price_Group_2);
                        //SetDropDownListValue(SA_Price_Group_3, cst.SA_Price_Group_3);
                        SA_Price_Group_1.Text = cst.SA_Price_Group_1;
                        SA_Price_Group_2.Text = cst.SA_Price_Group_2;
                        SA_Price_Group_3.Text = cst.SA_Price_Group_3;

                        SA_Complete_Delivery_Reqd_By_Law.Checked = cst.SA_Complete_Delivery_Reqd_By_Law == "1";
                        SA_Order_Combination.Checked = cst.SA_Order_Combination == "1";

                        SA_Customer.Checked = cst.SA_Customer == "1";
                        SA_Payment_History_Record.Checked = cst.SA_Payment_History_Record == "1";
                        SA_Switch_Off_Rounding.Checked              = cst.SA_Switch_Off_Rounding=="1";
                        SA_Relevant_For_POD.Checked                 = cst.SA_Relevant_For_POD=="1";
                        SA_Delivery_Priority.Text                   = cst.SA_Delivery_Priority;
                        SA_Shipping_Condition.Text                  = cst.SA_Shipping_Condition;
                        SA_Rebate.Checked                           = cst.SA_Rebate=="1";
                        SA_Price_Determin.Checked                   = cst.SA_Price_Determin=="1";
                        SA_Acct_Assgmt_Group.Text                   = cst.SA_Acct_Assgmt_Group;
                        SA_Tax_Classification.Text                  = cst.SA_Tax_Classification;
                        SA_Itcoterms.Text                           = cst.SA_Itcoterms;
                        SA_Max_Partial_Deliveries_1.Text = cst.SA_Max_Partial_Deliveries_1;
                        SA_Max_Partial_Deliveries_2.Text = cst.SA_Max_Partial_Deliveries_2;
                        SA_Max_Partial_Deliveries_3.Text = cst.SA_Max_Partial_Deliveries_3;
                        SA_Partial_Delivery_Per_Item_1.Text = cst.SA_Partial_Delivery_Per_Item_1;
                        SA_Partial_Delivery_Per_Item_2.Text = cst.SA_Partial_Delivery_Per_Item_2;
                        SA_Partial_Delivery_Per_Item_2.Text = cst.SA_Partial_Delivery_Per_Item_3;
                        SetDropDownListValue(SA_Terms_Of_Payment, cst.SA_Terms_Of_Payment);

                        SetDropDownListValue(SA_Attributes_1, cst.SA_Attributes_1);

                        
                        //SetDropDownListValue(SA_Attributes_2, cst.SA_Attributes_2);
                        //SetDropDownListValue(SA_Attributes_3, cst.SA_Attributes_3);
                        //SetDropDownListValue(SA_Attributes_4, cst.SA_Attributes_4);
                        //SetDropDownListValue(SA_Attributes_6, cst.SA_Attributes_6);

                        SA_Attributes_9.Text                        = cst.SA_Attributes_9;
                        SA_Customer_Group_2.Text                    = cst.SA_Customer_Group_2;
                        SetDropDownListValue(SA_Customer_Group_3, cst.SA_Customer_Group_3);
                        //SA_Customer_Group_3.Text                    = cst.SA_Customer_Group_3;
                        //State_owned_L.Checked                       = cst.State_owned_L=="1";
                        //Foreign_Company_L.Checked                   = cst.Foreign_Company_L=="1";
                        //AN_IG_L.Checked                             = cst.AN_IG_L=="1";
                        //Collective_L.Checked                        = cst.Collective_L=="1";
                        //Private_Enterpris_L.Checked                 = cst.Private_Enterpris_L=="1";
                        //Other_L.Checked                             = cst.Other_L=="1";
                        //SA_Ultimate_Holding_Company.Text            = cst.SA_Ultimate_Holding_Company;
                        //SA_Paid_In_Capital.Text                     = cst.SA_Paid_In_Capital;
                        //SA_Date_Established_Incorporated.Text       = cst.SA_Date_Established_Incorporated;

                        //SetDropDownListValue(SA_Invoice_Type, cst.SA_Invoice_Type);
                        //if (flg)
                        //{
                        //    SA_Invoice_Type_SelectedIndexChanged(null, e);
                        //}

                        //SetDropDownListValue(SA_Attributes5, cst.SA_Attributes5);

                        //SA_Existed_Fiscal_Address_Code_1.Text       = cst.SA_Existed_Fiscal_Address_Code_1;
                        //SA_Invoice_Name.Text                        = cst.SA_Invoice_Name;
                        //SA_Region.Text                              = cst.SA_Region;
                        //SA_City.Text                                = cst.SA_City;
                        //SA_Street5.Text                             = cst.SA_Street5;
                        //SA_City2.Text                               = cst.SA_City2;
                        //SA_District.Text                            = cst.SA_District;
                        //SA_Street.Text                              = cst.SA_Street;
                        //SA_Tel.Text                                 = cst.SA_Tel;
                        //SA_Tax_Code.Text                            = cst.SA_Tax_Code;
                        SA_Bank_Name.Text                           = cst.SA_Bank_Name;
                        SA_Bank_Country.Text = cst.SA_Bank_Country;
                        SA_Bank_Key.Text = cst.SA_Bank_Key;
                        SA_Bank_Statement.Text = cst.SA_Bank_Statement;
                        SA_Account.Text                             = cst.SA_Account;
                        FI_Recon_Account.Text                       = cst.FI_Recon_Account;
                        //SetDropDownListValue(FI_Recon_Account, cst.FI_Recon_Account);
                        FI_Sort_Key.Text                            = cst.FI_Sort_Key;
                        FI_Cash_Mgmt_Group.Text                     = cst.FI_Cash_Mgmt_Group;
                        FI_Dunn_Procrdure.Text                      = cst.FI_Dunn_Procrdure;
                        FI_Payment_Method.Text                      = cst.FI_Payment_Method;
                        FI_Terms_Of_Payment.Text = cst.FI_Terms_Of_Payment;
                        //FI_Account_Clerk.Text                       = cst.FI_Account_Clerk;
                        //FI_Customer_User.Text                       = cst.FI_Customer_User;
                        //FI_Act_Clk_Tel_NO.Text                      = cst.FI_Act_Clk_Tel_NO;
                        //FI_Account_Memo.Text                        = cst.FI_Account_Memo;
                        OT_Estimated_Volume.Text                    = cst.OT_Estimated_Volume;
                        OT_Estimated_Amount.Text                    = cst.OT_Estimated_Amount;
                        OT_Currency.Text                            = cst.OT_Currency;
                        OT_Remarks_1.Text                           = cst.OT_Remarks_1;
                        OT_Remarks_2.Text                           = cst.OT_Remarks_2;
                        OT_Remarks_3.Text                           = cst.OT_Remarks_3;
                        OT_Remarks_4.Text                           = cst.OT_Remarks_4;
                        //OT_Remarks_5.Text                           = cst.OT_Remarks_5;
                        //OT_Remarks_6.Text                           = cst.OT_Remarks_6;
                        //OT_Remarks_7.Text                           = cst.OT_Remarks_7;
                        OT_Credit_Terms_1.Text = cst.OT_Credit_Terms_1;
                        OT_Credit_Terms_2.Text = cst.OT_Credit_Terms_2;
                        OT_Credit_Limit.Text = cst.OT_Credit_Limit;
                        OT_Security_If_any.Text                     = cst.OT_Security_If_any;
                        OT_Credit_Limit_Proposed.Text               = cst.OT_Credit_Limit_Proposed;
                        OT_Credit_Limit_Approved.Text               = cst.OT_Credit_Limit_Approved;
                        OT_Credit_Terms_Proposed.Text               = cst.OT_Credit_Terms_Proposed;
                        OT_Credit_Terms_Approved.Text               = cst.OT_Credit_Terms_Approved;
                        cmd_OT_Comment_By_Sales_Department.Text     = cst.cmd_OT_Comment_By_Sales_Department;
                        cmd_OT_Comment_By_Credit_Control_Department.Text = cst.cmd_OT_Comment_By_Credit_Control_Department;
                       
                        SAP_Code.Text                               = cst.SAP_Code;
                        SetDropDownListValue(DMO_DrpPriority, cst.DMO_DrpPriority);
                        DMO_Arrpvoe_Creation_Number.Text = cst.DMO_Arrpvoe_Creation_Number;
                        DMO_Arrpvoe_Creation_Time.Text = cst.DMO_Arrpvoe_Creation_Time;
                        DMO_Maintain_Creation_Number.Text = cst.DMO_Maintain_Creation_Number;
                        DMO_Maintain_Creation_Time.Text = cst.DMO_Maintain_Creation_Time;
                        DMO_Check_Creation_Number.Text = cst.DMO_Check_Creation_Number;
                        DMO_Check_Creation_Time.Text = cst.DMO_Check_Creation_Time;
                        DMO_Arrpvoe_Revision_Number.Text = cst.DMO_Arrpvoe_Revision_Number;
                        DMO_Arrpvoe_Revision_Time.Text = cst.DMO_Arrpvoe_Revision_Time;
                        DMO_Maintain_Revision_Number.Text = cst.DMO_Maintain_Revision_Number;
                        DMO_Maintain_Revision_Time.Text = cst.DMO_Maintain_Revision_Time;
                        DMO_Check_Revision_Number.Text = cst.DMO_Check_Revision_Number;
                        DMO_Check_Revision_Time.Text = cst.DMO_Check_Revision_Time;
                    }
                    #endregion

                    #region 审批项初始化
                    switch (TaskAPI.Step)
                    {
                        case "DMO Approve":
                        case "DMO Maintain":
                        case "DMO Check":
                            Assessment1.Option.Add(new t_AssessmentOption("Finish", "1", true));
                            Assessment1.Option.Add(new t_AssessmentOption("Return", "2", false));
                            break;
                    }
                    #endregion
                 }
                #endregion

                SetDefaultValue();
                InitTabs();

                #region 设置控件禁启用

                SetEnable(flg, Actions, Keys, DrpPriority,BA_Cust_Pric, BA_Language, OT_Credit_Limit, OT_Credit_Terms_1, SA_Bank_Name, BA_Customer_Name_In_ZH, BA_Business_License_No, BA_Existed_Sold_To_Code, BA_Block_Existed_Code, BA_Contact_Person, BA_Contact_Person_Mobile_Phone, BA_Responsible_Man, BA_Responsible_Mobile_Phone, BA_Sales_Employee_K1, BA_Sales_Employee_K1_Mobile_Phone, BA_Sales_Employee_K2, BA_Sales_Employee_K2_Mobile_Phone, BA_Sales_Employee_K3, BA_Sales_Employee_K3_Mobile_Phone, BA_Sales_Employee_K1_Ot, BA_Sales_Employee_K2_Ot, BA_Sales_Employee_K3_Ot, BA_Sales_Employee_K1_Mobile_Phone_Ot, BA_Sales_Employee_K2_Mobile_Phone_Ot, BA_Sales_Employee_K3_Mobile_Phone_Ot, BA_Sales_Employee_K6, BA_Sales_Employee_K6_Mobile_Phone, BA_Sales_Employee_K6_Ot, BA_Sales_Employee_K6_Mobile_Phone_Ot, BA_Existed_Sold_To_Code_Country, BA_Existed_Sold_To_Code_City, BA_Existed_Sold_To_Code_Address, BA_Existed_Sold_To_Code_Contact_Preson, BA_Existed_Sold_To_Code_Tel, BA_Existed_Bill_To_Code, BA_Existed_Bill_To_Code_Country, BA_Existed_Bill_To_Code_City, BA_Existed_Bill_To_Code_Address, BA_Existed_Bill_To_Code_Contact_Preson, BA_Existed_Bill_To_Code_Tel, BA_Existed_Dunn_Recipient_Code, BA_Existed_Dunn_Recipient_Country, BA_Existed_Dunn_Recipient_City, BA_Existed_Dunn_Recipient_Address, BA_Existed_Dunn_Recipient_Contact_Preson, BA_Existed_Dunn_Recipient_Tel, BA_Industry, BA_Industry1, SA_Customer_Division_K1, SA_Customer_Division_K2, SA_Customer_Division_K3, SA_Customer_Division_K6, SA_Attributes_1, SA_Customer_Group_3, SA_Terms_Of_Payment, SA_Bank_Country, SA_Bank_Key, SA_Account, OT_Estimated_Volume, OT_Estimated_Amount, OT_Remarks_1, OT_Remarks_2, OT_Remarks_3, OT_Remarks_4, OT_Security_If_any, OT_Credit_Limit_Proposed, OT_Credit_Limit_Approved, OT_Credit_Terms_Proposed, OT_Credit_Terms_Approved, cmd_OT_Comment_By_Sales_Department, cmd_OT_Comment_By_Credit_Control_Department);
                SetEnable(TaskAPI.Step == "DMO Maintain" && TaskAPI.IsAllowSubmit, SAP_Code);
                SetEnable(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", DMO_DrpPriority, DMO_Arrpvoe_Creation_Number, DMO_Arrpvoe_Creation_Time, DMO_Maintain_Creation_Number, DMO_Maintain_Creation_Time, DMO_Check_Creation_Number, DMO_Check_Creation_Time, DMO_Arrpvoe_Revision_Number, DMO_Arrpvoe_Revision_Time, DMO_Maintain_Revision_Number, DMO_Maintain_Revision_Time, DMO_Check_Revision_Number, DMO_Check_Revision_Time);
                SetVisible(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", P_DMO);
                //SetEnable(TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Check", WorkLoad);
                SetVisible(TaskAPI.IsAllowSubmit, Send, Split);

                //if (TaskAPI.Step == "DMO Approve")
                //{
                //    SetForeColor(Color.Blue, DMO_DrpPriority_L);
                //}

                if (TaskAPI.Step == "DMO Approve" & Actions.SelectedValue == "1")
                {
                    SetForeColor(Color.Blue, DMO_Arrpvoe_Creation_L);
                }
                if (TaskAPI.Step == "DMO Maintain" & Actions.SelectedValue == "1")
                {
                    SetForeColor(Color.Blue, DMO_Maintain_Creation_L);
                }
                if (TaskAPI.Step == "DMO Check" & Actions.SelectedValue == "1")
                {
                    SetForeColor(Color.Blue, DMO_Check_Creation_L);
                }
                if (TaskAPI.Step == "DMO Approve" & Actions.SelectedValue != "1")
                {
                    SetForeColor(Color.Blue, DMO_Arrpvoe_Revision_L);
                }
                if (TaskAPI.Step == "DMO Maintain" & Actions.SelectedValue != "1")
                {
                    SetForeColor(Color.Blue, DMO_Maintain_Revision_L);
                }
                if (TaskAPI.Step == "DMO Check" & Actions.SelectedValue != "1")
                {
                    SetForeColor(Color.Blue, DMO_Check_Revision_L);
                }
                Assessment1.Enable = TaskAPI.IsAllowSubmit;
                Attachment1.AllowDelete = flg;
                Attachment1.AllowUpload = flg;
                #endregion

                #region 颜色加深
                if (!flg || !TaskAPI.IsAllowSubmit)
                {
                    foreach (Control cr in P1.Controls)
                    {
                        if (cr is TextBox)
                        {
                            TextBox tb = (TextBox)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ReadOnly = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }
                    foreach (Control cr in P1.Controls)
                    {
                        if (cr is DropDownList)
                        {
                            DropDownList tb = (DropDownList)cr;
                            if (!tb.Enabled)
                            {
                                tb.Enabled = true;
                                tb.ForeColor = System.Drawing.Color.DimGray;
                            }
                        }
                    }

                    //this.Actions.Enabled = true;
                }
                #endregion
            }
        }
        #endregion

        #region 事件 Send
        protected void Send_Click(object sender, EventArgs e)
        {
            try
            {
                #region 数据验证
                List<string> vald_s = new List<string>();
                List<Regular> regs = new List<Regular>();

                if ((TaskAPI.IsBeginStep || TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Check" || TaskAPI.Step == "DMO Approve") && TaskAPI.IsAllowSubmit)// 如果是退回的情况，不存在验证
                {
                    vald_s.AddRange(DataValidation());
                    vald_s.AddRange(ShipTo1.DataValidation());
                }
                
                //switch (TaskAPI.Step)
                //{
                //    case "DMO Approve":
                //    case "DMO Maintain":
                //    case "DMO Check":
                //        if (Assessment1.Assessment.Opinion == "2")
                //        {
                //            regs.Add(new Regular(RegularExp.NotEmpty, Assessment1.Assessment.Remark, "Opinion:退回时，退回理由(Remark备注) 必填"));
                //        }
                //        break;

                    //default:
                    //    regs.Add(new Regular(RegularExp.NotEmpty, Assessment1.Assessment.Remark, "Opinion:申请理由(Remark备注) 必填"));
                    //    break;
               // }

                vald_s.AddRange(Validation(regs));
                if (vald_s.Count > 0)
                {
                    Anthem.Manager.AddScriptForClientSideEval(string.Format("ShowMessage(\"{0}\", {1});", CombineMessage(vald_s), vald_s.Count));
                    return;
                }
            

                //新增workload验证代码
                //if (Assessment1.Assessment.Opinion == "1")
                //{
                    //不要这句List<string> vald_s = new List<string>();
                //    vald_s.AddRange(DataValidations());

                //    if (vald_s.Count > 0)
                //    {
                //        Anthem.Manager.AddScriptForClientSideEval(string.Format("ShowMessage(\"{0}\", {1});", CombineMessage(vald_s), vald_s.Count));
                //        return;
                //    }
                //}
                #endregion
                
                #region 引擎传值
                if (TaskAPI.IsBeginStep || TaskAPI.Step == "CA Check" || TaskAPI.Step == "RSM/RPM")
                {
                    if (TaskAPI.IsInitiate)
                    {
                        TaskAPI.UserName          = UserAPI.UserName;
                        ApplicationNo.Text        = Util.GenerateSequence(((object[])TaskAPI["PrefixNo"])[0].ToString() + "-" + System.DateTime.Now.ToString("yyMM"), "", 4);
                        TaskAPI["ApplicationNo"]  = ApplicationNo.Text;
                        TaskAPI["ApplicatorName"] = UserAPI.UserFullName;
                        TaskAPI["Applicator"]     = UserAPI.UserName;
                        TaskAPI["ApplicatorEmail"]= UserAPI.Mail;
                        TaskAPI["Department"]     = UserAPI.Department;
                        TaskAPI["Remark_by_Initiator"] = Assessment1.Assessment.Remark;
                        TaskAPI["Time"]           = System.DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                        TaskAPI["ServerName"] = Util.AppSettings("ServerName");
                    }
                    
                    TaskAPI.Summary = (Actions.SelectedItem.Text.Split(',').Length >= 2 ? Actions.SelectedItem.Text.Split(',')[1].Trim() : Actions.Text)
                                    + " / " + ApplicationNo.Text + (Keys.Items[0].Selected ? " / Sold To " : "") + (Keys.Items[1].Selected ? " / Ship To " : "");

                    //TaskAPI["isHierarchy"]        = Hierarchy.Visible ? "1": "0";  
                    TaskAPI["Actions"]            = Actions.SelectedValue;
                    TaskAPI["DrpPriority"] = DrpPriority.SelectedItem.Text;
                    //TaskAPI["BA_Industry3"]       = BA_Industry3.Text;
                    //TaskAPI["BA_Industry2"]       = BA_Industry2.Text;
                    //TaskAPI["BA_Hierarchy_2"]     = BA_Hierarchy_2.Text;
                    //TaskAPI["BA_Hierarchy_1"]     = BA_Hierarchy_1.Text;
                    //TaskAPI["IsCN88"] = BA_Sales_Office.Text;

                    if (TaskAPI.IsBeginStep)
                    {
                        #region 从数据库取得流程步骤处理人
                        if (TaskAPI.IsBeginStep)
                        {
                            SortedList<string, string> rec_a = new SortedList<string, string>();
                            IList<mdc_Recipient> rec_s = (mdc_Recipient.process == TaskAPI.Process & mdc_Recipient.status == 1).List<mdc_Recipient>();
                            foreach (mdc_Recipient rec in rec_s)
                            {
                                if (!rec_a.ContainsKey(rec.Step))
                                {
                                    rec_a.Add(rec.Step, rec.Recipient);
                                    continue;
                                }

                                if (rec_a.Values[rec_a.IndexOfKey(rec.Step)].Contains(rec.Recipient))
                                {
                                    continue;
                                }
                                rec_a[rec.Step] = rec_a.Values[rec_a.IndexOfKey(rec.Step)] + "," + rec.Recipient;
                            }

                            //步骤处理人赋值
                            for (int i = 0; i < rec_a.Keys.Count; i++)
                            {
                                TaskAPI["R_" + rec_a.Keys[i].Replace(" ", "_").Replace("/", "_")] = rec_a.Values[i].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                            }

                        }
                        #endregion
  
                    }
                   
                }
                
                if(!TaskAPI.IsBeginStep)
                {
                    TaskAPI["ApproveResult"] = Assessment1.Assessment.Opinion;
                    TaskAPI["TaskID"]        = TaskAPI.TaskID;

                    #region 退回到某个步骤的处理人
                    if (TaskAPI["R_" + TaskAPI.Step.Replace(" ", "_").Replace("/", "_")] != null)
                    {
                        object[] obj = (object[])(TaskAPI["R_" + TaskAPI.Step.Replace(" ", "_").Replace("/", "_")]);
                        for (int i = 0; i < obj.Length; i++)
                        {
                            obj[i] = null;
                        }

                        obj[0] = UserAPI.UserName;

                        TaskAPI["R_" + TaskAPI.Step.Replace(" ", "_").Replace("/", "_")] = obj;
                    }
                    #endregion
                }

                //#region 退回步骤并返回功能 传值
                //if (!string.IsNullOrEmpty(Assessment1.JumpStep))
                //{
                //    TaskAPI["Step"] = Assessment1.JumpStep;
                //    TaskAPI["PreStep"] = TaskAPI.Step;
                //}
                //else
                //{
                //    string PreStep = ((object[])TaskAPI["PreStep"])[0].ToString();
                //    if (PreStep.Trim() != "")
                //    {
                //        TaskAPI["Step"] = PreStep;
                //        TaskAPI["PreStep"] = "";
                //    }
                //    else
                //    {
                //        TaskAPI["Step"] = "";
                //        TaskAPI["PreStep"] = "";
                //    }
                //}

                //#endregion
                

                #endregion

                #region 提交步骤
                Storage.TransactionExecute(o =>
                {
                    #region “Fill in the form”步骤
                    if (TaskAPI.IsBeginStep )
                    {
                        hcmd_Customer cst = new hcmd_Customer();
                        if ((hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == TaskAPI.Incident).Count<hcmd_Customer>() > 0)
                        {
                            cst = (hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == TaskAPI.Incident).ListFirst<hcmd_Customer>();
                        }
                        else
                        {
                            cst.Process         = TaskAPI.Process;
                            cst.Incident        = TaskAPI.Incident;
                            cst.UserName        = UserAPI.UserName;
                            cst.UserFullName    = UserAPI.UserFullName;
                            cst.ApplicationNo   = ApplicationNo.Text;
                            cst.Time            = System.DateTime.Now;
                            cst.Status          = 1;
                            cst.Department      = UserAPI.Department;
                        }

                        cst.Actions = Actions.SelectedValue;
                        cst.DrpPriority = DrpPriority.SelectedValue;
                        //cst.WorkLoad_L = WorkLoad_L.Text;

                        cst.Keys    = Keys.Items[0].Selected ? "1" : "0";
                        cst.Keys2   = Keys.Items[1].Selected ? "1" : "0";
                        //cst.Keys3   = Keys.Items[2].Selected ? "1" : "0";
                       

                        #region Sold To
                        if (Keys.Items[0].Selected)
                        {
                            cst.BA_Customer_Name_In_ZH                 = BA_Customer_Name_In_ZH.Text;
                            cst.BA_Business_License_No                 = BA_Business_License_No.Text;
                            cst.BA_Existed_Sold_To_Code                = BA_Existed_Sold_To_Code.Text;
                            cst.BA_Block_Existed_Code                  = BA_Block_Existed_Code.SelectedValue;
                            cst.BA_Language                            = BA_Language.SelectedValue;
                            cst.BA_Cust_Pric                           = BA_Cust_Pric.SelectedValue;
                            cst.BA_Contact_Person                      = BA_Contact_Person.Text;
                            cst.BA_Contact_Person_Mobile_Phone         = BA_Contact_Person_Mobile_Phone.Text;
                            cst.BA_Responsible_Man                     = BA_Responsible_Man.Text;
                            cst.BA_Responsible_Mobile_Phone            = BA_Responsible_Mobile_Phone.Text;
                            cst.BA_Sales_Employee_K1                   = BA_Sales_Employee_K1.SelectedValue;
                            cst.BA_Sales_Employee_K1_Ot                = BA_Sales_Employee_K1_Ot.SelectedValue;
                            cst.BA_Sales_Employee_K1_Mobile_Phone      = BA_Sales_Employee_K1_Mobile_Phone.Text;
                            cst.BA_Sales_Employee_K1_Mobile_Phone_Ot   = BA_Sales_Employee_K1_Mobile_Phone_Ot.Text;
                            //cst.BA_Sales_Employee_K1_Employee_Code     = BA_Sales_Employee_K1_Employee_Code.Text;
                            cst.BA_Sales_Employee_K2                   = BA_Sales_Employee_K2.SelectedValue;
                            cst.BA_Sales_Employee_K2_Ot                = BA_Sales_Employee_K2_Ot.SelectedValue;
                            cst.BA_Sales_Employee_K2_Mobile_Phone      = BA_Sales_Employee_K2_Mobile_Phone.Text;
                            cst.BA_Sales_Employee_K2_Mobile_Phone_Ot = BA_Sales_Employee_K2_Mobile_Phone_Ot.Text;
                            //cst.BA_Sales_Employee_K2_Employee_Code     = BA_Sales_Employee_K2_Employee_Code.Text;
                            cst.BA_Sales_Employee_K3                   = BA_Sales_Employee_K3.SelectedValue;
                            cst.BA_Sales_Employee_K3_Ot                = BA_Sales_Employee_K3_Ot.SelectedValue;
                            cst.BA_Sales_Employee_K3_Mobile_Phone      = BA_Sales_Employee_K3_Mobile_Phone.Text;
                            cst.BA_Sales_Employee_K3_Mobile_Phone_Ot   = BA_Sales_Employee_K3_Mobile_Phone_Ot.Text;
                            cst.BA_Sales_Employee_K6 = BA_Sales_Employee_K6.SelectedValue;
                            cst.BA_Sales_Employee_K6_Ot = BA_Sales_Employee_K6_Ot.SelectedValue;
                            cst.BA_Sales_Employee_K6_Mobile_Phone = BA_Sales_Employee_K6_Mobile_Phone.Text;
                            cst.BA_Sales_Employee_K6_Mobile_Phone_Ot = BA_Sales_Employee_K6_Mobile_Phone_Ot.Text;
                            //cst.BA_Sales_Employee_K3_Employee_Code     = BA_Sales_Employee_K3_Employee_Code.Text;
                            cst.BA_Existed_Sold_To_Code_2              = BA_Existed_Sold_To_Code_2.Text;
                            cst.BA_Existed_Sold_To_Code_Country        = BA_Existed_Sold_To_Code_Country.SelectedValue;
                            cst.BA_Existed_Sold_To_Code_City           = BA_Existed_Sold_To_Code_City.SelectedValue;
                            
                            cst.BA_Existed_Sold_To_Code_Address        = BA_Existed_Sold_To_Code_Address.Text;
                            cst.BA_Existed_Sold_To_Code_Contact_Preson = BA_Existed_Sold_To_Code_Contact_Preson.Text;
                            cst.BA_Existed_Sold_To_Code_Tel            = BA_Existed_Sold_To_Code_Tel.Text;
                            
                            cst.BA_Existed_Bill_To_Code                = BA_Existed_Bill_To_Code.Text;
                            cst.BA_Existed_Bill_To_Code_Country        = BA_Existed_Bill_To_Code_Country.SelectedValue;
                            cst.BA_Existed_Bill_To_Code_City           = BA_Existed_Bill_To_Code_City.Text;
                            
                           
                            cst.BA_Existed_Bill_To_Code_Address         = BA_Existed_Bill_To_Code_Address.Text;
                            cst.BA_Existed_Bill_To_Code_Contact_Preson = BA_Existed_Bill_To_Code_Contact_Preson.Text;
                            cst.BA_Existed_Bill_To_Code_Tel            = BA_Existed_Bill_To_Code_Tel.Text;
                            cst.BA_DEL_Bill                             = BA_DEL_Bill.Text;
                            
                            cst.BA_Existed_Dunn_Recipient_Code         = BA_Existed_Dunn_Recipient_Code.Text;
                            cst.BA_Existed_Dunn_Recipient_Country     = BA_Existed_Dunn_Recipient_Country.SelectedValue;
                            cst.BA_Existed_Dunn_Recipient_City         = BA_Existed_Dunn_Recipient_City.Text;
                           
                            cst.BA_Existed_Dunn_Recipient_Address      = BA_Existed_Dunn_Recipient_Address.Text;
                            cst.BA_Existed_Dunn_Recipient_Contact_Preson = BA_Existed_Dunn_Recipient_Contact_Preson.Text;
                            cst.BA_Existed_Dunn_Recipient_Tel          = BA_Existed_Dunn_Recipient_Tel.Text;
                           
                            
                            cst.BA_Region                              = BA_Region.Text;
                            cst.BA_City_Code                           = BA_City_Code.Text;
                            //cst.BA_County_Code                         = BA_County_Code.Text;
                            cst.BA_Transportation_Zone                 = BA_Transportation_Zone.Text;
                            cst.BA_Industry                            = BA_Industry.SelectedValue;
                            cst.BA_Industry1                           = BA_Industry1.SelectedValue;
                            
                            cst.SA_Sales_Org                           = SA_Sales_Org.Text;
                            //cst.SA_Sales_Office                        = SA_Sales_Office.Text;
                            //cst.SA_Distribution_Channel                = SA_Distribution_Channel.Text;
                            //cst.SA_Sales_Employee                      = SA_Sales_Employee.Text;
                            //cst.SA_Sales_Employee_Code                 = SA_Sales_Employee_Code.Text;
                            cst.SA_Customer_Division_K1                = SA_Customer_Division_K1.Checked ? "1" : "0";
                            cst.SA_Customer_Division_K2                = SA_Customer_Division_K2.Checked ? "1" : "0";
                            cst.SA_Customer_Division_K3                = SA_Customer_Division_K3.Checked ? "1" : "0";
                            cst.SA_Customer_Division_K6 = SA_Customer_Division_K6.Checked ? "1" : "0";
                            cst.SA_Price_Group_1                       = SA_Price_Group_1.Text;
                            cst.SA_Price_Group_2                       = SA_Price_Group_2.Text;
                            cst.SA_Price_Group_3                       = SA_Price_Group_3.Text;
                            cst.SA_Max_Partial_Deliveries_1 = SA_Max_Partial_Deliveries_1.Text;
                            cst.SA_Max_Partial_Deliveries_2 = SA_Max_Partial_Deliveries_2.Text;
                            cst.SA_Max_Partial_Deliveries_3 = SA_Max_Partial_Deliveries_3.Text;
                            cst.SA_Partial_Delivery_Per_Item_1 = SA_Partial_Delivery_Per_Item_1.Text;
                            cst.SA_Partial_Delivery_Per_Item_2 = SA_Partial_Delivery_Per_Item_2.Text;
                            cst.SA_Partial_Delivery_Per_Item_3 = SA_Partial_Delivery_Per_Item_3.Text; 

                            cst.SA_Customer = SA_Customer.Checked ? "1" : "0";
                            cst.SA_Payment_History_Record = SA_Payment_History_Record.Checked ? "1" : "0";
                            cst.SA_Complete_Delivery_Reqd_By_Law=SA_Complete_Delivery_Reqd_By_Law.Checked?"1":"0";
                            cst.SA_Order_Combination = SA_Order_Combination.Checked ? "1" : "0";
                            cst.SA_Switch_Off_Rounding                 = SA_Switch_Off_Rounding.Checked ? "1" : "0";
                            cst.SA_Relevant_For_POD                    = SA_Relevant_For_POD.Checked ? "1" : "0";
                            cst.SA_Delivery_Priority                   = SA_Delivery_Priority.Text;
                            cst.SA_Shipping_Condition                  = SA_Shipping_Condition.Text;
                            cst.SA_Rebate                              = SA_Rebate.Checked ? "1" : "0";
                            cst.SA_Price_Determin                      = SA_Price_Determin.Checked ? "1" : "0";
                            cst.SA_Acct_Assgmt_Group                   = SA_Acct_Assgmt_Group.Text;
                            cst.SA_Tax_Classification                  = SA_Tax_Classification.Text;
                            cst.SA_Itcoterms                           = SA_Itcoterms.Text;
                            cst.SA_Terms_Of_Payment                    = SA_Terms_Of_Payment.SelectedValue;
                            cst.SA_Attributes_1                        = SA_Attributes_1.SelectedValue;
                            //cst.SA_Attributes_2                        = SA_Attributes_2.SelectedValue;
                            //cst.SA_Attributes_3                        = SA_Attributes_3.SelectedValue;
                            //cst.SA_Attributes_4                        = SA_Attributes_4.SelectedValue;
                            //cst.SA_Attributes_6                        = SA_Attributes_6.SelectedValue;
                            cst.SA_Attributes_9                        = SA_Attributes_9.Text;
                            cst.SA_Customer_Group_2                    = SA_Customer_Group_2.Text;
                            cst.SA_Customer_Group_3                    = SA_Customer_Group_3.SelectedValue;
                            cst.SA_Bank_Statement = SA_Bank_Statement.Text;
                            //cst.SA_Customer_Group_3                    = SA_Customer_Group_3.Text;
                            //cst.State_owned_L                          = State_owned_L.Checked ? "1" : "0";
                            //cst.Foreign_Company_L                      = Foreign_Company_L.Checked ? "1" : "0";
                            //cst.AN_IG_L                                = AN_IG_L.Checked ? "1" : "0";
                            //cst.Collective_L                           = Collective_L.Checked ?"1" : "0";
                            //cst.Private_Enterpris_L                    = Private_Enterpris_L.Checked ? "1" : "0";
                            //cst.Other_L                                = Other_L.Checked ?"1" : "0";
                            //cst.SA_Ultimate_Holding_Company            = SA_Ultimate_Holding_Company.Text;
                            //cst.SA_Paid_In_Capital                     = SA_Paid_In_Capital.Text;
                            //cst.SA_Date_Established_Incorporated       = SA_Date_Established_Incorporated.Text;
                            //cst.SA_Invoice_Type                        = SA_Invoice_Type.SelectedValue;
                            //cst.SA_Attributes5                         = SA_Attributes5.SelectedValue;
                            //cst.SA_Existed_Fiscal_Address_Code_1       = SA_Existed_Fiscal_Address_Code_1.Text;
                            //cst.SA_Invoice_Name                        = SA_Invoice_Name.Text;
                            //cst.SA_Region                              = SA_Region.Text;
                            //cst.SA_City                                = SA_City.Text;
                            //cst.SA_Street5                             = SA_Street5.Text;
                            //cst.SA_City2                               = SA_City2.Text;
                            //cst.SA_District                            = SA_District.Text;
                            //cst.SA_Street                              = SA_Street.Text;
                            //cst.SA_Tel                                 = SA_Tel.Text;
                            //cst.SA_Tax_Code                            = SA_Tax_Code.Text;
                            cst.SA_Bank_Name                           = SA_Bank_Name.Text;
                            cst.SA_Bank_Country = SA_Bank_Country.Text;
                            cst.SA_Bank_Key = SA_Bank_Key.Text;
                            cst.SA_Account                             = SA_Account.Text;
                            cst.FI_Recon_Account                       = FI_Recon_Account.Text;
                            cst.FI_Sort_Key                            = FI_Sort_Key.Text;
                            cst.FI_Cash_Mgmt_Group                     = FI_Cash_Mgmt_Group.Text;
                            cst.FI_Dunn_Procrdure                      = FI_Dunn_Procrdure.Text;
                            cst.FI_Payment_Method                      = FI_Payment_Method.Text;
                            cst.FI_Terms_Of_Payment = FI_Terms_Of_Payment.Text;
                            
                            //cst.FI_Account_Clerk                       = FI_Account_Clerk.Text;
                            //cst.FI_Customer_User                       = FI_Customer_User.Text;
                            //cst.FI_Act_Clk_Tel_NO                      = FI_Act_Clk_Tel_NO.Text;
                            //cst.FI_Account_Memo                        = FI_Account_Memo.Text;
                            cst.OT_Estimated_Volume                    = OT_Estimated_Volume.Text;
                            cst.OT_Estimated_Amount                    = OT_Estimated_Amount.Text;
                            cst.OT_Currency                            = OT_Currency.Text;
                            cst.OT_Remarks_1                           = OT_Remarks_1.Text;
                            cst.OT_Remarks_2                           = OT_Remarks_2.Text;
                            cst.OT_Remarks_3                           = OT_Remarks_3.Text;
                            cst.OT_Remarks_4                           = OT_Remarks_4.Text;
                            cst.OT_Credit_Limit = OT_Credit_Limit.Text;
                            cst.OT_Credit_Terms_1 = OT_Credit_Terms_1.Text;
                            cst.OT_Credit_Terms_2 = OT_Credit_Terms_2.Text;
                            //cst.OT_Remarks_5                           = OT_Remarks_5.Text;
                            //cst.OT_Remarks_6                           = OT_Remarks_6.Text;
                            //cst.OT_Remarks_7                           = OT_Remarks_7.Text;
                            cst.OT_Security_If_any                     = OT_Security_If_any.Text;
                            cst.OT_Credit_Limit_Proposed               = OT_Credit_Limit_Proposed.Text;
                            cst.OT_Credit_Limit_Approved               = OT_Credit_Limit_Approved.Text;
                            cst.OT_Credit_Terms_Proposed               = OT_Credit_Terms_Proposed.Text;
                            cst.OT_Credit_Terms_Approved               = OT_Credit_Terms_Approved.Text;
                            cst.cmd_OT_Comment_By_Sales_Department      = cmd_OT_Comment_By_Sales_Department.Text;
                            cst.cmd_OT_Comment_By_Credit_Control_Department = cmd_OT_Comment_By_Credit_Control_Department.Text;
                        }
                        #endregion

                        #region Ship To
                        //if (Keys.Items[1].Selected )
                        //{
                            ShipTo1.Save();
                        //}

                        #endregion

                       

                        Storage.Save(Storage.Context1, cst);
                    }
                     #endregion
                    #region Priority功能
                    if (TaskAPI.IsBeginStep && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = new mdc_Priority();
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = new mdc_Priority();
                            pro.Process = TaskAPI.Process;
                            pro.Incident = TaskAPI.Incident;
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }

                    }


                    if ((TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check") && !string.IsNullOrEmpty(this.DMO_DrpPriority.SelectedValue) && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {

                        //mdc_Priority pro;
                        //pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                        //pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                        //Storage.Save(pro);
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }


                    }
                    #endregion

                    #region “DMO Maintain”步骤
                    if (TaskAPI.Step == "DMO Maintain")
                    {
                        (hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == TaskAPI.Incident).Edit<hcmd_Customer>(p =>
                        {
                            p.SAP_Code = SAP_Code.Text;
                            //SetEnable(true, WorkLoad);
                            //p.WorkLoad = WorkLoad.Text;
                        }
                        );
                    }
                    if (TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check")
                    {

                        TaskAPI["DMO_DrpPriority"] = DMO_DrpPriority.SelectedItem.Text;
                        (hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == TaskAPI.Incident).Edit<hcmd_Customer>(p =>
                        {
                            // p.SAP_Code = SAP_Code.Text;
                            p.DMO_DrpPriority = DMO_DrpPriority.SelectedValue;
                            p.DMO_Arrpvoe_Creation_Number = DMO_Arrpvoe_Creation_Number.Text;
                            p.DMO_Arrpvoe_Creation_Time = DMO_Arrpvoe_Creation_Time.Text;
                            p.DMO_Maintain_Creation_Number = DMO_Maintain_Creation_Number.Text;
                            p.DMO_Maintain_Creation_Time = DMO_Maintain_Creation_Time.Text;
                            p.DMO_Check_Creation_Number = DMO_Check_Creation_Number.Text;
                            p.DMO_Check_Creation_Time = DMO_Check_Creation_Time.Text;
                            p.DMO_Arrpvoe_Revision_Number = DMO_Arrpvoe_Revision_Number.Text;
                            p.DMO_Arrpvoe_Revision_Time = DMO_Arrpvoe_Revision_Time.Text;
                            p.DMO_Maintain_Revision_Number = DMO_Maintain_Revision_Number.Text;
                            p.DMO_Maintain_Revision_Time = DMO_Maintain_Revision_Time.Text;
                            p.DMO_Check_Revision_Number = DMO_Check_Revision_Number.Text;
                            p.DMO_Check_Revision_Time = DMO_Check_Revision_Time.Text;

                            //p.DMO_SalesSAP_Code = DMO_SalesSAP_Code.Text;
                        }
                        );
                    }
                     #endregion

                    #region
                    //if (TaskAPI.Step == "DMO Check")
                    //{
                    //    (hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == TaskAPI.Incident).Edit<hcmd_Customer>(p =>
                    //    {
                    //        SetEnable(true, WorkLoad);
                    //        p.WorkLoad = WorkLoad.Text;

                    //    });
                    //}

                    //if (TaskAPI.Step == "DMO Approve")
                    //{
                    //    (hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == TaskAPI.Incident).Edit<hcmd_Customer>(p =>
                    //    {
                    //        SetEnable(true, WorkLoad);
                    //        p.WorkLoad = WorkLoad.Text;

                    //    });
                    //}

                    #endregion

                    Storage.Save(Assessment1.Assessment);
                });

                //多节点退回
                if (!string.IsNullOrEmpty(Assessment1.JumpStep))
                {
                    Assessment1.SetAsReturn(true);
                    TaskAPI.DirectActive(Assessment1.JumpStep);
                }
                else
                {
                    Assessment1.SetAsReturn(false);
                }

                Assessment1.SubmitTo();
                TaskAPI.Send();

                //如果数据库写入成功且流程发起成功的情况，将业务表数据与流程实例号进行关联
                if (TaskAPI.IsInitiate)
                {

                    if (!string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == 0).Edit<mdc_Priority>(p =>
                        {
                            p.Incident = TaskAPI.Incident;
                        });
                    }
                    (hcmd_Customer.process == TaskAPI.Process & hcmd_Customer.incident == 0 & hcmd_Customer.user == (TaskAPI.IsInitiate ? UserAPI.UserName : TaskAPI.UserName)).Edit<hcmd_Customer>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });

                    (hcmd_ShipTo.process == TaskAPI.Process & hcmd_ShipTo.incident == 0 & hcmd_ShipTo.userName == (TaskAPI.IsInitiate ? UserAPI.UserName : TaskAPI.UserName)).Edit<hcmd_ShipTo>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });

                    (t_Assessment.process == TaskAPI.Process & t_Assessment.incident == 0 & t_Assessment.userName == (TaskAPI.IsInitiate ? UserAPI.UserName : TaskAPI.UserName)).Edit<t_Assessment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });

                    (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == 0 & t_Attachment.username == (TaskAPI.IsInitiate ? UserAPI.UserName : TaskAPI.UserName)).Edit<t_Attachment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });
                }
                #endregion

                Send.Visible = false;




                StoreAPI.ClearKey(TaskID);
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Success + "',true)");
            }
            catch (Exception ex)
            {
                TaskDB.Log("", false, "调用CMD方法Send_Click出错：" + ex.ToString());
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Failed + "',false)");
            }
        }

        /// <summary>
        /// 当division是K1的时候，将K1的sheet数和原有的数字相加
        /// </summary>
        /// <returns></returns>
        //private int CalculateK1Count()
        //{
        //    int k1Count = 0;
        //    foreach (hcmd_ShipTo s in ShipTo1.ShipTos)
        //    {
        //        if (s.ST_Division.Equals("k1", StringComparison.InvariantCultureIgnoreCase))
        //            k1Count++;
        //    }
        //    return k1Count;
        //}
        
        #endregion

        #region 事件 Actions
        protected void Actions_SelectedIndexChanged(object sender, EventArgs e)
        {
            SetColor();
            if (Actions.SelectedValue == "1")
            {
                BA_Existed_Sold_To_Code.Visible = false;
                BA_Existed_Sold_To_Code_L.Visible = false;
                
                
                BA_Existed_Sold_To_Code_2.Text = "";

            }
            else
            {
                BA_Existed_Sold_To_Code.Visible = true;
                BA_Existed_Sold_To_Code_L.Visible = true;
                BA_Existed_Sold_To_Code_2.Text = BA_Existed_Sold_To_Code.Text;
               
            }
            if (Keys.Items[1].Selected && Actions.SelectedValue == "1" && (!Keys.Items[0].Selected))
            {
                SetForeColor(Color.Blue, ShipTo1.ST_Sold_To_No_L);
                //SetForeColor(Color.Black, ShipTo1.ST_Sold_To_Name_L);
            }
            //WorkLoad_L.Text = Actions.SelectedItem.Text.Substring(3);
        }
        #endregion

        #region 事件 Tabs切换
        protected void MM_Click(object sender, EventArgs e)
        {
            if (((LinkButton)sender).CssClass == "tabs2")
            {
                return;
            }

            #region 初始化
            SetVisible(false, P1, P2);
            SoldTo.CssClass     = "tabs1";
            ShipTo.CssClass     = "tabs1";
            //Hierarchy.CssClass  = "tabs1";
            #endregion

            #region Tabs切换动作
            switch (((LinkButton)sender).ID)
            {
                case "SoldTo":
                    SoldTo.CssClass = "tabs2";
                    P1.Visible = true;
                    break;
                case "ShipTo":
                    ShipTo.CssClass = "tabs2";
                    P2.Visible = true;
                    break;
                //case "Hierarchy":
                //    Hierarchy.CssClass = "tabs2";
                //    P3.Visible = true;
                //    break;
            }
            #endregion
        }
        #endregion

        #region 事件 Tabs 选择
        protected void Key_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!Keys.Items[0].Selected && !Keys.Items[1].Selected)
            {
                if (SoldTo.CssClass == "tabs2")
                {
                    Keys.Items[0].Selected = true;
                }
                else if (ShipTo.CssClass == "tabs2")
                {
                    Keys.Items[1].Selected = true;
                }
                //else
                //{
                //    Keys.Items[2].Selected = true;
                //}

                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('至少保留一个选择项！',false)");
            }

            InitTabs();
        }
        #endregion

        #region 事件 Customer Name in ZH
        protected void BA_Customer_Name_In_ZH_TextChanged(object sender, EventArgs e)
        {
            if (Keys.Items[0].Selected && Keys.Items[1].Selected && Actions.SelectedValue == "1")
            {
                ShipTo1.ST_Sold_To_Name.Text = BA_Customer_Name_In_ZH.Text;
                //ShipTo1.ST_Sold_To_Name_2.Text = BA_Customer_Name_In_ZH.Text;
            }
        }
        #endregion

        //#region 事件 对帐单联系人和电话
        //protected void BA_Existed_Dunn_Recipient_Contact_Preson_TextChanged(object sender, EventArgs e)
        //{
        //    if (BA_Existed_Dunn_Recipient_Contact_Preson.Text != "")
        //    {
        //        FI_Customer_User.Text = BA_Existed_Dunn_Recipient_Contact_Preson.Text;

        //    }
        //    else
        //    {
        //        FI_Customer_User.Text = "";
        //    }
        //}


        //protected void BA_Existed_Dunn_Recipient_Tel_TextChanged(object sender, EventArgs e)
        //{
        //    if (BA_Existed_Dunn_Recipient_Tel.Text != "")
        //    {
        //        FI_Act_Clk_Tel_NO.Text = BA_Existed_Dunn_Recipient_Tel.Text;
        //    }
        //    else
        //    {
        //        FI_Act_Clk_Tel_NO.Text = "";
        //    }
        //}
        //#endregion

        #region 事件 Existed Code
        protected void BA_Existed_Bill_To_Code_TextChanged(object sender, EventArgs e)
        {
            if (Actions.SelectedValue != "1")
            {
                if (BA_Existed_Bill_To_Code.Text != BA_Existed_Sold_To_Code.Text)
                {
                    BA_Existed_Sold_To_Code_3.Text = "";
                }
                else
                {
                    BA_Existed_Sold_To_Code_3.Text = "请删除原bill to，并新建一个bill to";
                }
            }
        }

        protected void BA_Existed_Dunn_Recipient_Code_TextChanged(object sender, EventArgs e)
        {
            if (Actions.SelectedValue != "1")
            {
                if (BA_Existed_Dunn_Recipient_Code.Text != BA_Existed_Sold_To_Code.Text)
                {
                    BA_Existed_Dunn_Recipient_Code2.Text = "";
                }
                else
                {
                    BA_Existed_Dunn_Recipient_Code2.Text = "请删除原对帐单code，并新建一个对帐单code";
                }
            }
        }

        //protected void SA_Existed_Fiscal_Address_Code_1_TextChanged(object sender, EventArgs e)
        //{
        //    if (Actions.SelectedValue != "1")
        //    {
        //        if (SA_Existed_Fiscal_Address_Code_1.Text != BA_Existed_Sold_To_Code.Text)
        //        {
        //            SA_Existed_Fiscal_Address_Code_2.Text = "";
        //        }
        //        else
        //        {
        //            SA_Existed_Fiscal_Address_Code_2.Text = "请删除原Fiscal address code并新建一个Fiscal address code";
        //        }
        //    }
        //}

        #endregion

        #region 事件 BA_Existed_Sold_To_Code
        protected void BA_Existed_Sold_To_Code_TextChanged(object sender, EventArgs e)
        {

            if (Actions.SelectedValue == "1")
            {
                BA_Existed_Sold_To_Code.Visible = false;
                BA_Existed_Sold_To_Code_L.Visible = false;
                BA_Existed_Sold_To_Code_2.Text = "";

           
            }
            else
            {
                BA_Existed_Sold_To_Code.Visible = true;
                BA_Existed_Sold_To_Code_L.Visible = true;
                BA_Existed_Sold_To_Code_2.Text = BA_Existed_Sold_To_Code.Text;

     
            }
        }
        #endregion

        #region 事件 Emloyee and code必填
        protected void SA_Sales_Employee_TextChanged(object sender, EventArgs e)
        {
            //string id = (sender as Anthem.TextBox).ID;
            //switch (id)
            //{
            //    case "BA_Sales_Employee_K1":
            //        {
            //            if (BA_Sales_Employee_K1.Text != "")
            //            {
            //                m_Employee_Code me = (m_Employee_Code.persNo == (sender as TextBox).Text).ListFirst<m_Employee_Code>();
            //                if (me != null)
            //                {
            //                    BA_Sales_Employee_K1_Employee_Code.Text = me.Employee;
            //                }
            //            }
            //            else
            //            {
            //                BA_Sales_Employee_K1_Employee_Code.Text = "";
            //            }

            //        }
            //        break;
            //    case "BA_Sales_Employee_K2":
            //        {
            //            if (BA_Sales_Employee_K2.Text != "")
            //            {
            //                m_Employee_Code me2 = (m_Employee_Code.persNo == (sender as TextBox).Text).ListFirst<m_Employee_Code>();
            //                if (me2 != null)
            //                {
            //                    BA_Sales_Employee_K2_Employee_Code.Text = me2.Employee;
            //                }
            //            }
            //            else
            //            {
            //                BA_Sales_Employee_K2_Employee_Code.Text = "";
            //            }
            //        }
            //        break;
            //    case "BA_Sales_Employee_K3":
            //        {

            //            if (BA_Sales_Employee_K3.Text != "")
            //            {
            //                m_Employee_Code me3 = (m_Employee_Code.persNo == (sender as TextBox).Text).ListFirst<m_Employee_Code>();
            //                if (me3 != null)
            //                {
            //                    BA_Sales_Employee_K3_Employee_Code.Text = me3.Employee;
            //                }
            //            }
            //            else
            //            {
            //                BA_Sales_Employee_K3_Employee_Code.Text = "";
            //            }
            //        }
            //        break;
            //}
            //if (id == "BA_Sales_Employee_K1_Employee_Code" || id == "BA_Sales_Employee_K2_Employee_Code" || id == "BA_Sales_Employee_K3_Employee_Code")
            //{
            //    SA_Sales_Employee_Code.Text = BA_Sales_Employee_K1.Text + "/" + BA_Sales_Employee_K2.Text + "/" + BA_Sales_Employee_K3.Text;
            //    return;
            //}
            
            if (Actions.SelectedValue=="1" && BA_Sales_Employee_K1.Text != "")
            {
                SetForeColor(Color.Blue,  SA_Customer_Division_K1_L);
            }
            else
            {
                SetForeColor(Color.Black,  SA_Customer_Division_K1_L);
            }

            if (Actions.SelectedValue == "1" && BA_Sales_Employee_K2.Text != "")
            {
                SetForeColor(Color.Blue, SA_Customer_Division_K2_L);
            }
            else
            {
                SetForeColor(Color.Black,  SA_Customer_Division_K2_L);
            }

            if (Actions.SelectedValue == "1" && BA_Sales_Employee_K3.Text != "")
            {
                SetForeColor(Color.Blue, SA_Customer_Division_K3_L);
            }
            else
            {
                SetForeColor(Color.Black, SA_Customer_Division_K3_L);
            }

            if (Actions.SelectedValue == "1" && BA_Sales_Employee_K6.Text != "")
            {
                SetForeColor(Color.Blue, SA_Customer_Division_K6_L);
            }
            else
            {
                SetForeColor(Color.Black, SA_Customer_Division_K6_L);
            }
            //SA_Sales_Employee.Text = BA_Sales_Employee_K1_Employee_Code.Text + "/" + BA_Sales_Employee_K2_Employee_Code.Text + "/" + BA_Sales_Employee_K3_Employee_Code.Text;
            //SA_Sales_Employee_Code.Text = BA_Sales_Employee_K1.Text + "/" + BA_Sales_Employee_K2.Text + "/" + BA_Sales_Employee_K3.Text;
            
        }

        #endregion

       
            




    

        #region 事件 K1

        #region 事件 Retail-K1—必填
        protected void SA_Customer_Division_K1_CheckedChanged(object sender, EventArgs e)
        {
            if (Actions.SelectedValue == "1" && SA_Customer_Division_K1.Checked)
            {
                SetForeColor(Color.Blue, BA_Sales_Employee_K1_L);
               
            }
            else
            {
                SetForeColor(Color.Black, BA_Sales_Employee_K1_L);
                
            }
        }
        #endregion

        #endregion

        #region 事件 K2

        #region 事件 Retail-K2—必填
        protected void SA_Customer_Division_K2_CheckedChanged(object sender, EventArgs e)
        {
            if (Actions.SelectedValue == "1" && SA_Customer_Division_K2.Checked)
            {
                SetForeColor(Color.Blue, BA_Sales_Employee_K2_L);
               
            }
            else
            {
                SetForeColor(Color.Black, BA_Sales_Employee_K2_L);
            }
        }
        #endregion

        

        #endregion

        #region 事件 K3/河南百安居
        #region 事件 Retail-K3—必填
        protected void SA_Customer_Division_K3_CheckedChanged(object sender, EventArgs e)
        {
            if (Actions.SelectedValue == "1" && SA_Customer_Division_K3.Checked)
            {
                SetForeColor(Color.Blue, BA_Sales_Employee_K3_L);
            }
            else
            {
                SetForeColor(Color.Black, BA_Sales_Employee_K3_L);
            }
        }
        #endregion
        #endregion

        #region 事件 K6/河南百安居
        #region 事件 New Biz-K6—必填
        protected void SA_Customer_Division_K6_CheckedChanged(object sender, EventArgs e)
        {
            if (Actions.SelectedValue == "1" && SA_Customer_Division_K6.Checked)
            {
                SetForeColor(Color.Blue, BA_Sales_Employee_K6_L);
            }
            else
            {
                SetForeColor(Color.Black, BA_Sales_Employee_K6_L);
            }
        }
        #endregion
        #endregion

        //#region 事件 APO Customer (K1)
        //protected void SA_Price_Group_1_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    SA_APO_Customer_Group_APO_K1.Text = "";
        //    if (SA_Price_Group_1.Text == "")
        //    {
        //        SA_APO_Customer_Group_APO_K1.Text = "";
        //    }
        //    else
        //    {
        //        IList<m_APO_Customer_List> sac = (m_APO_Customer_List.status == 1 & (m_APO_Customer_List.final_Name == (BA_Region.Text + SA_Price_Group_1.Text.Substring(4, 2) + BA_Transportation_Zone.Text)
        //         | m_APO_Customer_List.final_Name == "")).List<m_APO_Customer_List>();
        //        foreach (m_APO_Customer_List SA in sac)
        //        {

        //            SA_APO_Customer_Group_APO_K1.Text = SA.APO_Customer_Description;

        //        }
        //    }
        //}
        //#endregion

        //#region 事件 APO Customer (K2)
        //protected void SA_Price_Group_2_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    SA_APO_Customer_Group_APO_K2.Text = "";
        //    if (SA_Price_Group_2.Text == "")
        //    {
        //        SA_APO_Customer_Group_APO_K2.Text = "";
        //    }
        //    else
        //    {
        //        IList<m_APO_Customer_List> sac2 = (m_APO_Customer_List.status == 1 & (m_APO_Customer_List.final_Name == (BA_Region.Text + SA_Price_Group_2.Text.Substring(4, 2) + BA_Transportation_Zone.Text)
        //         | m_APO_Customer_List.final_Name == "")).List<m_APO_Customer_List>();
        //        foreach (m_APO_Customer_List SA in sac2)
        //        {

        //            SA_APO_Customer_Group_APO_K2.Text = SA.APO_Customer_Description;

        //        }
        //    }

        //}
        //#endregion

        //#region 事件 APO Customer (K3)
        //protected void SA_Price_Group_3_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    SA_APO_Customer_Group_APO_K3.Text = "";
        //    if (SA_Price_Group_3.Text == "")
        //    {
        //        SA_APO_Customer_Group_APO_K3.Text = "";
        //    }
        //    else
        //    {
        //        IList<m_APO_Customer_List> sac3 = (m_APO_Customer_List.status == 1 & (m_APO_Customer_List.final_Name == (BA_Region.Text + SA_Price_Group_3.Text.Substring(4, 2) + BA_Transportation_Zone.Text)
        //         | m_APO_Customer_List.final_Name == "")).List<m_APO_Customer_List>();
        //        foreach (m_APO_Customer_List SA in sac3)
        //        {

        //            SA_APO_Customer_Group_APO_K3.Text = SA.APO_Customer_Description;

        //        }
        //    }

        //}
        //#endregion

        #region 方法 InitTabs
        protected void InitTabs()
        {
            SoldTo.Visible      = Keys.Items[0].Selected;
            ShipTo.Visible      = Keys.Items[1].Selected;
            //Hierarchy.Visible   = Keys.Items[2].Selected;

            if ((SoldTo.CssClass == "tabs2" && Keys.Items[0].Selected)
             || (ShipTo.CssClass == "tabs2" && Keys.Items[1].Selected))
            {
                return;
            }

            SetVisible(false, P1, P2);
            SoldTo.CssClass = "tabs1";
            ShipTo.CssClass = "tabs1";
            //Hierarchy.CssClass = "tabs1";

            //默认第1个显示 Tabs被选中
            if (SoldTo.Visible)
            {
                SoldTo.CssClass = "tabs2";
                P1.Visible = true;
                return;
            }

            if (ShipTo.Visible)
            {
                ShipTo.CssClass = "tabs2";
                P2.Visible = true;
                return;
            }

            //if (Hierarchy.Visible)
            //{
            //    Hierarchy.CssClass = "tabs2";
            //    P3.Visible = true;
            //    return;
            //}
        }
        #endregion

        #region 方法 SetDefaultValue(设置默认值, 并禁用输入)
        public void SetDefaultValue()
        {
            
            BA_DEL_Bill.Text                    = "Yes";
           
            SA_Sales_Org.Text                   = "CN04";
            //SA_Distribution_Channel.Text        = "10,20";
            SA_Partial_Delivery_Per_Item_1.Text = " C";
            SA_Partial_Delivery_Per_Item_2.Text = " C";
            SA_Partial_Delivery_Per_Item_3.Text = " C";
            SA_Max_Partial_Deliveries_1.Text = "";
            SA_Max_Partial_Deliveries_2.Text = "";
            SA_Max_Partial_Deliveries_3.Text = "";
            SA_Price_Group_1.Text = "";
            SA_Price_Group_2.Text = "";
            SA_Price_Group_3.Text = "";
            
            SA_Customer.Checked=true;
            SA_Order_Combination.Checked = false;
            SA_Complete_Delivery_Reqd_By_Law.Checked = true;
            SA_Payment_History_Record.Checked = true;
            SA_Switch_Off_Rounding.Checked      = true;
            SA_Relevant_For_POD.Checked         = false;
            SA_Delivery_Priority.Text = "15";
            SA_Shipping_Condition.Text          = "01";
            SA_Rebate.Checked                   = true;
            SA_Price_Determin.Checked           = true;
            SA_Acct_Assgmt_Group.Text           = "01";
            SA_Tax_Classification.Text          = "0";
            SA_Itcoterms.Text                   = "Z01";
            SA_Bank_Statement.Text = "2";
            //SA_Terms_Of_Payment.Text            = "CN01 Payable immediately Due net";
            SA_Customer_Group_2.Text            = "001";
            //SA_Customer_Group_3.Text            = "001";
            FI_Recon_Account.Text = "2211000";
            FI_Sort_Key.Text                    = "001";
            FI_Cash_Mgmt_Group.Text             = "E1";
            FI_Dunn_Procrdure.Text              = "CN00";
            FI_Payment_Method.Text              = "U";
            OT_Currency.Text                    = "HKD";
            //OT_Credit_Terms_1.Text              = "C.O.D";

            SetEnable(false, SA_Bank_Statement,SA_Price_Group_1,SA_Price_Group_2,SA_Price_Group_3, SA_Customer, FI_Recon_Account,SA_Max_Partial_Deliveries_1, SA_Max_Partial_Deliveries_2, SA_Max_Partial_Deliveries_3, BA_DEL_Bill, SA_Sales_Org, SA_Partial_Delivery_Per_Item_1, SA_Partial_Delivery_Per_Item_2, SA_Partial_Delivery_Per_Item_3, SA_Order_Combination, SA_Complete_Delivery_Reqd_By_Law, SA_Payment_History_Record, SA_Switch_Off_Rounding, SA_Relevant_For_POD, SA_Delivery_Priority, SA_Shipping_Condition, SA_Rebate, SA_Price_Determin, SA_Acct_Assgmt_Group, SA_Tax_Classification, SA_Itcoterms, SA_Customer_Group_2, FI_Sort_Key, FI_Cash_Mgmt_Group, FI_Dunn_Procrdure, FI_Payment_Method, OT_Currency);
            SetForeColor(Color.Orange, SA_Price_Group_1_L, SA_Price_Group_2_L, SA_Price_Group_3_L,SA_Customer_L, SA_Bank_Statement_L, FI_Recon_Account_L, SA_Partial_Delivery_Per_Item_1_L, SA_Partial_Delivery_Per_Item_2_L, SA_Max_Partial_Deliveries_1_L, SA_Max_Partial_Deliveries_2_L, SA_Max_Partial_Deliveries_3_L, BA_DEL_Bill_L, SA_Sales_Org_L, SA_Order_Combination_L, SA_Partial_Delivery_Per_Item_1, SA_Partial_Delivery_Per_Item_2, SA_Partial_Delivery_Per_Item_3_L, SA_Complete_Delivery_Reqd_By_Law_L, SA_Payment_History_Record_L, SA_Switch_Off_Rounding_L, SA_Relevant_For_POD_L, SA_Delivery_Priority_L, SA_Shipping_Condition_L, SA_Rebate_L, SA_Price_Determin_L, SA_Acct_Assgmt_Group_L, SA_Tax_Classification_L, SA_Itcoterms_L, SA_Customer_Group_2_L, FI_Sort_Key_L, FI_Cash_Mgmt_Group_L, FI_Dunn_Procrdure_L, FI_Payment_Method_L, OT_Currency_L);
        }
        #endregion

        #region 方法 InitDropdownList 下拉框赋值
        private void InitDropDownList()
        {
            if (!IsLoaded)
            {

                #region Industry Code
                BA_Industry.Items.Clear();
                BA_Industry.Items.Add(new ListItem("", ""));
                IList<m_HK_Industry_Code> bis = (m_HK_Industry_Code.status == 1).List<m_HK_Industry_Code>();
                foreach (m_HK_Industry_Code BI in bis)
                {
                    BA_Industry.Items.Add(new ListItem(BI.Explanation, BI.Explanation));

                }
                #endregion

                #region Industry Code1
                BA_Industry1.Items.Clear();
                BA_Industry1.Items.Add(new ListItem("", ""));
                IList<m_Industry_Code1> bis1 = (m_Industry_Code1.status == 1).List<m_Industry_Code1>();
                foreach (m_Industry_Code1 BI in bis1)
                {
                    BA_Industry1.Items.Add(new ListItem(BI.Explanation, BI.Explanation));

                }
                #endregion

                #region Attributes_1
                SA_Attributes_1.Items.Clear();
                SA_Attributes_1.Items.Add(new ListItem("", ""));
                IList<m_HK_Attributes1> sa1 = (m_Attributes_1.status == 1).List<m_HK_Attributes1>();
                foreach (m_HK_Attributes1 SA in sa1)
                {
                    SA_Attributes_1.Items.Add(new ListItem(SA.Attributes_1, SA.Attributes_1));
                }
                #endregion

                #region Customer Group 3
                SA_Customer_Group_3.Items.Clear();
                SA_Customer_Group_3.Items.Add(new ListItem("", ""));
                IList<m_Customer_Group_3> cg1 = (m_Customer_Group_3.status == 1).List<m_Customer_Group_3>();
                foreach (m_Customer_Group_3 SA in cg1)
                {
                    SA_Customer_Group_3.Items.Add(new ListItem(SA.Customer_Group_3, SA.Customer_Group_3));
                }
                #endregion

                #region Payment Terms
                SA_Terms_Of_Payment.Items.Clear();
                SA_Terms_Of_Payment.Items.Add(new ListItem("", ""));
                //FI_Terms_Of_Payment.Items.Clear();
                //FI_Terms_Of_Payment.Items.Add(new ListItem("", ""));
                IList<m_HKcustomer_PaymentTerms> ge1 = (m_HKcustomer_PaymentTerms.status == 1).List<m_HKcustomer_PaymentTerms>();
                foreach (m_HKcustomer_PaymentTerms GE in ge1)
                {
                    SA_Terms_Of_Payment.Items.Add(new ListItem(GE.Payment_Terms, GE.Payment_Terms));
                    //FI_Terms_Of_Payment.Items.Add(new ListItem(GE.Payment_Terms, GE.Payment_Terms));
                }
                #endregion

                //#region Price Group
                //SA_Price_Group_1.Items.Clear();
                //SA_Price_Group_1.Items.Add(new ListItem("", ""));
                //SA_Price_Group_2.Items.Clear();
                //SA_Price_Group_2.Items.Add(new ListItem("", ""));
                //SA_Price_Group_3.Items.Clear();
                //SA_Price_Group_3.Items.Add(new ListItem("", ""));
                //IList<m_HK_PriceGroup> hp = (m_HK_PriceGroup.status == 1).List<m_HK_PriceGroup>();
                //foreach (m_HK_PriceGroup HP in hp)
                //{
                //    SA_Price_Group_1.Items.Add(new ListItem(HP.Price_Group, HP.Price_Group));
                //    SA_Price_Group_2.Items.Add(new ListItem(HP.Price_Group, HP.Price_Group));
                //    SA_Price_Group_3.Items.Add(new ListItem(HP.Price_Group, HP.Price_Group));
                //}
                //#endregion

                #region Employee
                BA_Sales_Employee_K1.Items.Clear();
                BA_Sales_Employee_K1.Items.Add(new ListItem("", ""));
                BA_Sales_Employee_K1_Ot.Items.Clear();
                BA_Sales_Employee_K1_Ot.Items.Add(new ListItem("", ""));
                BA_Sales_Employee_K2.Items.Clear();
                BA_Sales_Employee_K2.Items.Add(new ListItem("", ""));
                BA_Sales_Employee_K2_Ot.Items.Clear();
                BA_Sales_Employee_K2_Ot.Items.Add(new ListItem("", ""));
                BA_Sales_Employee_K3.Items.Clear();
                BA_Sales_Employee_K3.Items.Add(new ListItem("", ""));
                BA_Sales_Employee_K3_Ot.Items.Clear();
                BA_Sales_Employee_K3_Ot.Items.Add(new ListItem("", ""));
                BA_Sales_Employee_K6.Items.Clear();
                BA_Sales_Employee_K6.Items.Add(new ListItem("", ""));
                BA_Sales_Employee_K6_Ot.Items.Clear();
                BA_Sales_Employee_K6_Ot.Items.Add(new ListItem("", ""));
                IList<m_HK_Employee> he = (m_HK_Employee.status == 1).List<m_HK_Employee>();
                foreach (m_HK_Employee HE in he)
                {
                    BA_Sales_Employee_K1.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                    BA_Sales_Employee_K1_Ot.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                    BA_Sales_Employee_K2.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                    BA_Sales_Employee_K2_Ot.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                    BA_Sales_Employee_K3.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                    BA_Sales_Employee_K3_Ot.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                    BA_Sales_Employee_K6.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                    BA_Sales_Employee_K6_Ot.Items.Add(new ListItem(HE.HK_Employee, HE.HK_Employee));
                }
                #endregion


                //#region Attributes_2
                //SA_Attributes_2.Items.Clear();
                //SA_Attributes_2.Items.Add(new ListItem("", ""));
                //IList<m_Attributes_2> sa2 = (m_Attributes_2.status == 1).List<m_Attributes_2>();
                //foreach (m_Attributes_2 SA in sa2)
                //{
                //    SA_Attributes_2.Items.Add(new ListItem(SA.Brand_Segment, SA.Brand_Segment));

                //}
                //#endregion

                //#region Attributes_3
                //SA_Attributes_3.Items.Clear();
                //SA_Attributes_3.Items.Add(new ListItem("", ""));
                //IList<m_Attributes_3> sa3 = (m_Attributes_3.status == 1).List<m_Attributes_3>();
                //foreach (m_Attributes_3 SA in sa3)
                //{
                //    SA_Attributes_3.Items.Add(new ListItem(SA.Market_Segment, SA.Market_Segment));

                //}
                //#endregion

                //#region Attributes_4
                //SA_Attributes_4.Items.Clear();
                //SA_Attributes_4.Items.Add(new ListItem("", ""));
                //IList<m_Attributes_4> sa4 = (m_Attributes_4.status == 1).List<m_Attributes_4>();
                //foreach (m_Attributes_4 SA in sa4)
                //{
                //    SA_Attributes_4.Items.Add(new ListItem(SA.Sub_Market, SA.Sub_Market));

                //}
                //#endregion

                //#region Attributes_6
                //SA_Attributes_6.Items.Clear();
                //SA_Attributes_6.Items.Add(new ListItem("", ""));
                //IList<m_Attributes_6> sa6 = (m_Attributes_6.status == 1).List<m_Attributes_6>();
                //foreach (m_Attributes_6 SA in sa6)
                //{
                //    SA_Attributes_6.Items.Add(new ListItem(SA.Attributes_6, SA.Attributes_6));

                //}
                //#endregion

                //#region SA_Region
                //SA_Region.Items.Clear();
                //SA_Region.Items.Add(new ListItem("", ""));
                //IList<m_Sales_Office> sr = (m_Sales_Office.status == 1).List<m_Sales_Office>();
                //foreach (m_Sales_Office SR in sr)
                //{
                //    if (SA_Region.Items.FindByValue(SR.Region_Code_Name) == null)
                //    {
                //        SA_Region.Items.Add(new ListItem(SR.Region_Code_Name, SR.Region_Code_Name));
                //    }
                //}
                //#endregion

                //#region Invoice
                //SA_Invoice_Type.Items.Clear();
                //SA_Invoice_Type.Items.Add(new ListItem("", ""));
                //IList<m_Attributes_5> sits = (m_Attributes_5.status == 1).List<m_Attributes_5>();
                //foreach (m_Attributes_5 SIT in sits)
                //{
                //    if (SA_Invoice_Type.Items.FindByValue(SIT.Invoice_Type) == null)
                //    {
                //        SA_Invoice_Type.Items.Add(new ListItem(SIT.Invoice_Type, SIT.Invoice_Type));

                //    }
                //}
                //#endregion
            }
        }
        #endregion

        #region 方法 DataValidation 数据验证
        private List<string> DataValidation()
        {
            List<string> vald_s = new List<string>();
            List<string> vald_s_2 = new List<string>();
            List<Regular> regs = new List<Regular>();

            #region Sold To
            if (Keys.Items[0].Selected && Actions.SelectedValue == "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Customer_Name_In_ZH.Text, "Sold to: Customer Name 必填"));
                
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code_Country.SelectedValue, "Sold to: Customer Detailed Add.:Country 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code_City.SelectedValue, "Sold to: City & District 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Attributes_1.SelectedValue, "Sold to: Attributes1 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, Convert.ToString(SA_Customer_Division_K1.Checked) + Convert.ToString(SA_Customer_Division_K2.Checked) + Convert.ToString(SA_Customer_Division_K3.Checked) + Convert.ToString(SA_Customer_Division_K6.Checked), "Sold to:  1.Retail-K1 或 2.Project-K2 或 3.Modern Trade-K3 或 4.New Biz-K6 至少需要填寫一個"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K1.SelectedValue + BA_Sales_Employee_K2.SelectedValue + BA_Sales_Employee_K3.SelectedValue + BA_Sales_Employee_K6.SelectedValue, "Sold to:  Sales Person(K1) 或 Sales Person(K2) 或 Sales Person(K3) 或 Sales Person(K6) 至少需要填寫一個"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code_Address.Text, "Sold to: Customer Detailed Add.:Address 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, SA_Terms_Of_Payment.SelectedValue, "Sold to: Terms Of Payment 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code_Contact_Preson.Text, "Sold to: Customer Detailed Add.:Contact Person 必填"));
              
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Language.SelectedValue, "Sold to: Language 必填"));

                regs.Add(new Regular(RegularExp.NotEmpty, BA_Cust_Pric.SelectedValue, "Sold to: Cust.pric.proc. 必填"));
                //regs.Add(new Regular(RegularExp.NotEmpty, FI_Recon_Account.SelectedValue, "Sold to: Recon Account 必填"));
               

                //regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Bill_To_Code_Address.Text, "Sold to: Address on Invoice:Address 必填"));
                
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Industry.SelectedValue, "Sold to: Industry  必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Industry1.SelectedValue, "Sold to: Industry1 必填"));
                
             
               
                
                
                
              

                    
                #region K1
                if (SA_Customer_Division_K1.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K1.SelectedValue, "Sold to:  Sales Person(K1) 必填"));
                    //regs.Add(new Regular(RegularExp.NotEmpty, SA_Price_Group_1.SelectedValue, "Sold to: Price Group(K1) 必填"));
                }

                if (BA_Sales_Employee_K1.Text != "")
                {
                    //regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K1_Employee_Code.Text, "Sold to: Sales Employee(K1) 必填"));
                    regs.Add(new Regular(RegularExp.NotEmpty, SA_Customer_Division_K1.Checked ? "blank" : "", "Sold to: 1.Retail-K1 必填"));
                }

             

                #endregion

                #region K2
                if (SA_Customer_Division_K2.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K2.SelectedValue, "Sold to: Sales Person(K2) 必填"));
                   // regs.Add(new Regular(RegularExp.NotEmpty, SA_Price_Group_2.SelectedValue, "Sold to: Price Group(K2) 必填"));
                    //SetForeColor(Color.Blue, BA_Sales_Employee_K2_L,  SA_Price_Group_2_L, SA_Attributes_3_L, SA_Attributes_4_L);
                }

                if (BA_Sales_Employee_K2.Text != "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, SA_Customer_Division_K2.Checked ? "blank" : "", "Sold to: 2. Project-K2 必填"));
                    //regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K2_Employee_Code.Text, "Sold to: Sales Employee(K2) 必填"));
                   
                }

               
               
                #endregion

                #region K3
                if (SA_Customer_Division_K3.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K3.SelectedValue, "Sold to: Sales Person(K3) 必填"));
                    //regs.Add(new Regular(RegularExp.NotEmpty, SA_Price_Group_3.SelectedValue, "Sold to: Price Group(K3) 必填"));
                    SetForeColor(Color.Blue, BA_Sales_Employee_K3_L);
                }
                
                if (BA_Sales_Employee_K3.Text != "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, SA_Customer_Division_K3.Checked ? "blank" : "", "Sold to: 3.Modern Trade-K3 必填"));
                    //regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K3_Employee_Code.Text, "Sold to: Sales Employee(K3) 必填"));
                    SetForeColor(Color.Blue, SA_Customer_Division_K3_L);
                }

                #endregion

                #region K6
                if (SA_Customer_Division_K6.Checked)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K6.SelectedValue, "Sold to: Sales Person(K6) 必填"));
                    //regs.Add(new Regular(RegularExp.NotEmpty, SA_Price_Group_3.SelectedValue, "Sold to: Price Group(K3) 必填"));
                    SetForeColor(Color.Blue, BA_Sales_Employee_K6_L);
                }

                if (BA_Sales_Employee_K6.Text != "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, SA_Customer_Division_K6.Checked ? "blank" : "", "Sold to: 5.New Biz-K6 必填"));
                    //regs.Add(new Regular(RegularExp.NotEmpty, BA_Sales_Employee_K3_Employee_Code.Text, "Sold to: Sales Employee(K3) 必填"));
                    SetForeColor(Color.Blue, SA_Customer_Division_K6_L);
                }
                #endregion
            }

            if (Keys.Items[0].Selected && Actions.SelectedValue != "1")
            {
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Customer_Name_In_ZH.Text, "Sold to: Customer Name 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, BA_Existed_Sold_To_Code.Text, "Sold to: Existed Sold-to Code 必填"));
               
            }

            vald_s = Validation(regs);
            if (vald_s.Count > 0)
            {
                vald_s.Insert(0, "<font color='#0000FF'><b>Sold To </b></font>");
            }

            #endregion

            //if (TaskAPI.Step == "DMO Approve" & Assessment1.Assessment.Opinion == "1")
            //{
            //    regs.Add(new Regular(RegularExp.NotEmpty, DMO_DrpPriority.SelectedValue, " Priority 必填"));
            //}



            if (TaskAPI.Step == "DMO Approve" & Actions.SelectedValue == "1" & Assessment1.Assessment.Opinion == "1")
            {

                if (DMO_Arrpvoe_Creation_Number.Text == "" | DMO_Arrpvoe_Creation_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Approve的Creation项必填"));
                }

            }
            if (TaskAPI.Step == "DMO Maintain" & Actions.SelectedValue == "1" & Assessment1.Assessment.Opinion == "1")
            {

                if (DMO_Maintain_Creation_Number.Text == "" | DMO_Maintain_Creation_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Maintain的Creation项必填"));
                }

            }
            if (TaskAPI.Step == "DMO Check" & Actions.SelectedValue == "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Check_Creation_Number.Text == "" | DMO_Check_Creation_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Check的Creation项必填"));
                }

            }
            if (TaskAPI.Step == "DMO Approve" & Actions.SelectedValue != "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Arrpvoe_Revision_Number.Text == "" | DMO_Arrpvoe_Revision_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Approve的Revision项必填"));
                }
                //if (SA2.Checked & VD_Category.SelectedValue == "1")
                //{
                //    regs.Add(new Regular(RegularExp.NotEmpty, DMO_SalesSAP_Code.Text, "Sales SAP Code 必填"));
                //}
            }
            if (TaskAPI.Step == "DMO Maintain" & Actions.SelectedValue != "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Maintain_Revision_Number.Text == "" | DMO_Maintain_Revision_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Maintain的Revision项必填"));
                }

            }
            if (TaskAPI.Step == "DMO Check" & Actions.SelectedValue != "1" & Assessment1.Assessment.Opinion == "1")
            {
                if (DMO_Check_Revision_Number.Text == "" | DMO_Check_Revision_Time.Text == "")
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, "", " DMO Check的Revision项必填"));
                }

            }

            vald_s_2 = Validation(regs);

            if (vald_s_2.Count > 0)
            {

                vald_s.AddRange(vald_s_2);
            }

            return vald_s;
        }

        //新增workload数据验证方法
        //private List<string> DataValidations()
        //{
        //    List<Regular> regs = new List<Regular>();
        //    if (Actions.SelectedValue == "1" || Actions.SelectedValue == "2" || Actions.SelectedValue == "3" || Actions.SelectedValue == "4")
        //    {
        //        if (TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Check")
        //        {
        //            regs.Add(new Regular(RegularExp.NotEmpty, WorkLoad.Text.Trim(), WorkLoad_L.Text + "不能为空"));
        //        }
        //    }
        //    return Validation(regs);
        //}
        #endregion

        #region 方法 SetColor 设置颜色
        protected void SetColor()
        {
            SetForeColor(Color.Black, BA_Cust_Pric_L,BA_Language_L, SA_Attributes_1_L,  SA_Terms_Of_Payment_L, BA_Existed_Sold_To_Code_City_L, BA_Existed_Dunn_Recipient_Address_L, BA_Existed_Dunn_Recipient_Country_L, BA_Existed_Bill_To_Code_Address_L, BA_Existed_Bill_To_Code_Country_L, BA_Customer_Name_In_ZH_L, BA_Block_Existed_Code_L, BA_Existed_Sold_To_Code_L, BA_Customer_Name_In_ZH_L, BA_Existed_Sold_To_Code_Country_L, BA_Existed_Sold_To_Code_Address_L, BA_Existed_Sold_To_Code_Contact_Preson_L, BA_Industry_L, BA_Industry1_L, SA_Attributes_9_L);

            switch(Actions.SelectedValue)
            {
                case "1":
                    SetForeColor(Color.Blue, BA_Cust_Pric_L,BA_Language_L, SA_Attributes_1_L,  BA_Customer_Name_In_ZH_L, SA_Terms_Of_Payment_L, BA_Existed_Sold_To_Code_City_L, BA_Existed_Sold_To_Code_Country_L, BA_Customer_Name_In_ZH_L, BA_Existed_Sold_To_Code_Address_L, BA_Existed_Sold_To_Code_Address_L, BA_Existed_Sold_To_Code_Contact_Preson_L, BA_Industry_L, BA_Industry1_L);
                    break;

                case "2":
                    SetForeColor(Color.Blue, BA_Customer_Name_In_ZH_L,BA_Existed_Sold_To_Code_L);
                    break;

                case "3":
                    SetForeColor(Color.Blue, BA_Customer_Name_In_ZH_L,BA_Existed_Sold_To_Code_L);
                    break;
                
                case "4":
                    SetForeColor(Color.Blue, BA_Customer_Name_In_ZH_L,BA_Existed_Sold_To_Code_L);
                    break;
            }

            ShipTo1.SetColor();
        }
        #endregion

        #region 方法 SetCheckList 设置下拉框
        private Anthem.CheckBoxList setCheckList(string t, Anthem.CheckBoxList ck)
        {
            try
            {
                string[] tt = t.Split(',');

                for (int i = 0; i <= tt.GetUpperBound(0); i++)
                {
                    for (int j = 0; j < ck.Items.Count; j++)
                    {
                        if (ck.Items[j].Value == tt[i].ToString())
                        { ck.Items[j].Selected = true; break; }
                    }
                }
            }
            catch { }
            return ck;
        }
        #endregion

        #region 方法 SetDropDownListValue 设置下拉框默认值
        private void SetDropDownListValue(Anthem.DropDownList drpT, object o)
        {
            try
            {
                if ((TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit) || drpT.Items.FindByValue(o.ToString()) != null)
                {
                    drpT.SelectedValue = o.ToString();
                    return;
                }

                drpT.Items.Add(new ListItem(o.ToString(),o.ToString()));
                drpT.SelectedIndex = 0;

            }catch(Exception)
            {
            }
        }
        #endregion

        #region 重载 OnLoadComplete
        protected override void OnLoadComplete(EventArgs e)
        {
            if (!IsLoaded && TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit)
            {
                Actions_SelectedIndexChanged(null, e);
            }

            base.OnLoadComplete(e);
        }
        #endregion

        #region City和TransportationZone 
        //下拉框选中事件
        protected void BA_Existed_Sold_To_Code_Country_SelectedIndexChanged(object sender, EventArgs e)
        {

            switch (BA_Existed_Sold_To_Code_Country.SelectedValue)
              {
                  case "HK":
                      BA_City_Code.Text = "K683";
                      BA_Transportation_Zone.Text = "HKOTH00000";
                    break;

                  case "MO(MACAU)":
                     BA_City_Code.Text = "K684";
                     BA_Transportation_Zone.Text = "MOOTH00000";
                    break;

                default:
                    BA_City_Code.Text = "";
                    BA_Transportation_Zone.Text = "";
                    break;
            }
        }
        #endregion

        #region City和Region联动
        protected void BA_Existed_Sold_To_Code_City_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (BA_Existed_Sold_To_Code_City.SelectedValue)
            {
                case "HK Island":
                    BA_Region.Text = "HK";
                    SA_Attributes_9.Text = "330";
                    break;

                case "Kowloon":
                    BA_Region.Text = "KLN";
                    SA_Attributes_9.Text = "340";
                    break;

                case "New Territories":
                    BA_Region.Text = "NT";
                    SA_Attributes_9.Text = "350";
                    break;

                case "Macau":
                    BA_Region.Text = "MO";
                    SA_Attributes_9.Text = "360";
                    break;

                default:
                    BA_Region.Text = "";
                    SA_Attributes_9.Text = "";
                    break;
            }
        }
        #endregion

        #region Payment Terms 选中的值
        protected void SA_Terms_Of_Payment_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SA_Terms_Of_Payment.SelectedValue != "")
            {
                FI_Terms_Of_Payment.Text = SA_Terms_Of_Payment.Text;
                OT_Credit_Terms_2.Text = SA_Terms_Of_Payment.Text;
            }
            else
            {
                FI_Terms_Of_Payment.Text = "";
                OT_Credit_Terms_2.Text = "";
            }
        }
        #endregion

        

        
    }
}
